<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/sys/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加单据明细信息</title>
<%@ include file="/WEB-INF/sys/include/css.jsp"%>
</head>
<body>
<form id="form" action="${path}/inResMx/save.json" method="post">
<div class="form">
	<div class="group">
		<div class="label">*选择物品:</div>
		<div class="item">
			<input type="text" id="resName" name="resName" style="text-align:center" placeholder="选择" readonly="readonly" class="select_page" />
			<input type="hidden" name="resid" id="resid"/>
		</div>
		<div class="item" id="residTip"></div>
	</div>
	
	<div class="group">
		<div class="label">数量:</div>
		<div class="item"><input type="text" onchange="jisuan()" name="num" id="num"/></div>
	</div>
	<div class="group">
		<div class="label">价格:</div>
		<div class="item"><input type="text" onchange="jisuan()" name="price" id="price"/></div>
	</div>
	<div class="group">
		<div class="label">金额:</div>
		<div class="item"><input type="text" value="0.00" name="amount" id="amount"/></div>
	</div>
	<div class="group">
		<div class="label">备注:</div>
		<div class="item"><textarea id="remark" name="remark"></textarea></div>
	</div>
	<div class="buttons">
		<button class="highlight" id="submit1" type="button">确定</button>
		<button type="button" id="cancel1">取消</button>
		<input type="hidden" name="resCode" id="resCode"/>
		<input type="hidden" name="docketid" value="${docketid}"/>
		<input type="hidden" name="repertoryid" value="${repertoryid}"/>
	</div>
</div>
</form>
<%@ include file="/WEB-INF/sys/include/script.jsp" %>
<script type="text/javascript">
$(function() {
	function getLayerData(){
		return {
	    	resid: $("#resid").val()
	    };
	}
	$("#form").ligerForm({inputWidth: 300});
	
	verifyForm("form", {}, function(){
		$("#form").ajaxForm(function(data){
			UiUtil.isSuccess(data, "添加单据信息成功", function(){
				UiUtil.closeForm(true);
			});
		});
	});
	
	$("#submit1").click(function(){
		UiUtil.lockButton('submit1');
		$("#form").submit();
	});

	$("#cancel1").click(function(){
		UiUtil.closeForm();
	});
	$("#resName").click(function(){
		layer.open({
			type : 2,
			title : "选择物品",
			maxmin : false,
			shadeClose : false,
			area : [ '1100px', '650px' ],
			content : "${path}/res/selectRes.do",
			btn: ['确定', '取消'],
			yes:function(index, layero){
				var data = $(layero).find('iframe')[0].contentWindow.getSelectedData();
				if(data){
					$("#resName").val(data.resName);
            		$("#resid").val(data.resid);
            		$("#resCode").val(data.resDm);
				}else{
					$("#resName").val("");
            		$("#resid").val("");
            		$("#resCode").val("");
				}
				$("#resid").focus().blur();
				layer.close(index);
			},
			btn2: function(index){
				layer.close(index);
			}
		});
	});
	
});
function getLayerData(){
	return {
    	resid: $("#resid").val()
    };
}
function jisuan(){
	var price = $("#price").val();
	var num = $("#num").val();
	$("#amount").val(price*num);
}
</script>
</body>
</html>